<%-- 
    Document   : error
    Created on : Mar 23, 2012, 11:30:21 AM
    Author     : rj
--%>

<%

    String loginAttempt = request.getParameter("loginAttempt");
    if (loginAttempt != null) {
        boolean isValid = true;

        if (loginAttempt.indexOf("<") > -1) {
            isValid = false;
        } else if (loginAttempt.indexOf(">") > -1) {
            isValid = false;
        } else if (loginAttempt.indexOf("\"") > -1) {
            isValid = false;
        } else if (loginAttempt.indexOf("/") > -1) {
            isValid = false;
        } else if (loginAttempt.indexOf(":") > -1) {
            isValid = false;
        } else if (loginAttempt.indexOf(";") > -1) {
            isValid = false;
        } else if (loginAttempt.indexOf("=") > -1) {
            isValid = false;
        } else if (loginAttempt.indexOf("|") > -1) {
            isValid = false;
        }

        if (isValid == false) {
            loginAttempt = null;
        }
               }
     String loginAttemptMax = request.getParameter("loginMax");
    if (loginAttempt != null) {
        boolean isValidMax = true;

        if (loginAttemptMax.indexOf("<") > -1) {
            isValidMax = false;
        } else if (loginAttemptMax.indexOf(">") > -1) {
            isValidMax = false;
        } else if (loginAttemptMax.indexOf("\"") > -1) {
            isValidMax = false;
        } else if (loginAttemptMax.indexOf("/") > -1) {
            isValidMax = false;
        } else if (loginAttemptMax.indexOf(":") > -1) {
            isValidMax = false;
        } else if (loginAttemptMax.indexOf(";") > -1) {
            isValidMax = false;
        } else if (loginAttemptMax.indexOf("=") > -1) {
            isValidMax = false;
        } else if (loginAttemptMax.indexOf("|") > -1) {
            isValidMax = false;
        }

        if (isValidMax == false) {
            loginAttemptMax = null;
        }
    }
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="../css/foo.css" type="text/css"/>
        <link rel="stylesheet" type="text/css" href="../css/superfish.css" media="screen">	
        <title>Foobar</title>
        <script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="../js/hoverIntent.js"></script>
        <script type="text/javascript" src="../js/superfish.js"></script>
        <script type="text/javascript" src="../js/LoginValidation.js"></script>
        <script type="text/javascript">

            // initialise plugins
            jQuery(function(){
                jQuery('ul.sf-menu').superfish();
            });
            
            function checkAuth(){
              if(<%=request.getParameter("loginAttempt")%>==false && isValid){
                 document.write('<span class="errLog">Authentication failed.</span>');
               }
               else if (<%=request.getParameter("loginMax")%>==true && isValidMax){
                   document.write('<span class="errLog">You have reached your maximum login attempts. Please try again later.</span>');
               }
         }
           

        </script>
    </head>
    <body class="bg">
        <br/>
        <div class="hmenu">
            <% if (request.getSession(true).getAttribute("username") == null) {%>
<!--            <p style="font-size: 12px; margin-top: -15px; float: right;">If you're not yet a member, sign up <a href="../signUp.jsp" class="lin">here!</a> </p>   -->
            <% }%>
            <img src="../images/head.png" style="float: left; margin-left:20px;"/>
            <div>
<!--                <% if (request.getSession(true).getAttribute("username") != null) {%>
                <span>Hello <%=session.getAttribute("username")%>!</span><br>
                <span style="font-weight: normal; font-size: 10px;">You have <%=session.getAttribute("numCart")%> items in your cart.</span>
                <div id="nav">
                    <ul class="top">
                        <li><a href="../viewCart.jsp">View Cart</a></li>
                        <li><a href="../checkOut.jsp">Checkout</a></li>
                        <li><a href="../viewProfile.jsp">Account Details</a></li>
                        <li><a href="LogoutServlet">Log out</a></li>
                    </ul>-->
                </div>
                <% } else {%>
<!--                <span style="font-weight: bold;">Log in</span>
                <script type="text/javascript">checkAuth();</script>
                <form method="post" action="LoginServlet">
                    <label>Username:</label><input type="text" id="username" name="username"/><br/>
                    <label>Password:</label><input type="password" id="password" name="password"/><br/>
                    <input type="submit" onClick="return LoginValidation()" value="Log in" name="submit"/>
                    <label class="errLog" id="err"></label>
                </form>-->
                <% }%>
            </div>
        </div>
        <div class="content">
            <br/>
            <h1 align="left">404</h1>
            <p align="left">Oops! The page that you requested could not be found. Please click <a href="../index.jsp">here</a> to go back. :)</p>
        </div>
    </body>
</html>
